﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace luck_roll
{
    public partial class InputControlFrm : Form
    {
        private string _value = String.Empty;

        private int rgb = 0;

        public int RBG
        {
            get
            {
                return rgb;
            }
        }

        public string Value
        {
            get
            {
                return _value;
            }
        }
        public InputControlFrm()
        {
            InitializeComponent();
        }

        public InputControlFrm(string title, string lableContent, string value, bool showColor)
            : this()
        {
            this.Text = title;
            this.label1.Text = lableContent;
            this.tbValue.Text = value;

            this.panel1.Visible = showColor;

        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnConfrim_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.tbValue.Text))
            {
                MessageBox.Show("请输入有效的值");
                return;
            }
            this._value = this.tbValue.Text;
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btnSelectColor_Click(object sender, EventArgs e)
        {
            if (DialogResult.OK == this.colorDialog1.ShowDialog())
            {
                this.rgb = this.colorDialog1.Color.ToArgb();

                this.label3.ForeColor = Color.FromArgb(this.rgb);
            }
        }

        private void btnSetFont_Click(object sender, EventArgs e)
        {
            FontDialog fontDialog = new FontDialog();

            //是否允许修改字体样式
            fontDialog.AllowScriptChange = false;
            //是否允许修改颜色
            fontDialog.ShowColor = false;

            Font currnt = this.label3.Font;

            if (fontDialog.ShowDialog() == DialogResult.OK)
            {

                Font newFont = new Font(currnt.FontFamily, fontDialog.Font.Size);
                this.label3.Font = newFont;
            }
        }
    }
}
